package com.rd.student.dashuju.wangbo.exercise02;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;

public class ArraysDemo7 {
    public static void main(String[] args) {
        HashMap<String, String> hashMap = new HashMap<>();
        method(hashMap);
    }

    public static void method(HashMap<String, String> hashMap) {
        String[] s1 = new String[]{"哈尔滨", "大庆", "绥化", "齐齐哈尔", "杭州", "宁波", "南昌", "广州", "福州", "厦门"};
        String[] s2 = new String[]{"黑龙江省", "黑龙江省", "黑龙江省", "黑龙江省", "浙江省", "浙江省", "江西省", "广东省", "福建省", "福建省"};
        for (int i = 0; i < s1.length; i++) {
            String key = s1[i];
            String value = s2[i];
            hashMap.put(key, value);
        }

        Set<String> set = hashMap.keySet();
        Iterator<String> iterator = set.iterator();
        while (iterator.hasNext()) {
            String key = iterator.next();
            String value = hashMap.get(key);
            System.out.println(value + "=" + key);
        }

        int c = 1;
        for (int i = 1; i < s2.length; i++) {

            if (s2[i - 1] != s2[i] || s2[i - 1] == s2[s2.length - 1]) {
                if (s2[i - 1] == s2[s2.length - 1]) c++;
                System.out.println(s2[i - 1] + "," + c);
                c = 1;
            } else {
                c++;
            }

        }

    }
}
